// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_img.p_video;

import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.widget.ImageView;
import com.nnee.p_g.cls_b;

// Referenced classes of package com.nnee.p_img.p_video:
//            aj, an, o, p, 
//            v

public abstract class cls_ImageViewTouchBase extends  ImageView
{

    public cls_ImageViewTouchBase(Context context)
    {
        super(context);
        f = new Matrix();
        g = new Matrix();
        b = new Matrix();
        c = new float[9];
        h = new cls_aj(null);
        i = -1;
        j = -1;
        l = new Handler();
        o = null;
        m = true;
        h();
    }

    public cls_ImageViewTouchBase(Context context, AttributeSet attributeset)
    {
        super(context, attributeset);
        f = new Matrix();
        g = new Matrix();
        b = new Matrix();
        c = new float[9];
        h = new cls_aj(null);
        i = -1;
        j = -1;
        l = new Handler();
        o = null;
        m = true;
        h();
    }

    private void a(Bitmap bitmap, int i1)
    {
        super.setImageBitmap(bitmap);
        Drawable drawable = getDrawable();
        if(drawable != null)
            drawable.setDither(true);
        Bitmap bitmap1 = h.b();
        h.a(bitmap);
        h.a(i1);
        if(bitmap1 != null && bitmap1 != bitmap && e != null)
            e.a(bitmap1);
    }

    private void a(cls_aj aj1, Matrix matrix, boolean flag)
    {
        float f1 = getWidth();
        float f2 = getHeight();
        float f3 = aj1.f();
        float f4 = aj1.e();
        matrix.reset();
        float f5 = Math.min(f1 / f3, 3F);
        float f6 = Math.min(f2 / f4, 3F);
        float f7;
        if(flag)
            f7 = Math.max(f5, f6);
        else
            f7 = Math.min(f5, f6);
        matrix.postConcat(aj1.c());
        matrix.postScale(f7, f7);
        matrix.postTranslate((f1 - f3 * f7) / 2F, (f2 - f7 * f4) / 2F);
    }

    private void h()
    {
        setScaleType(android.widget.ImageView.ScaleType.MATRIX);
    }

    protected float a(Matrix matrix)
    {
        return a(matrix, 0);
    }

    protected float a(Matrix matrix, int i1)
    {
        matrix.getValues(c);
        return c[i1];
    }

    public void a()
    {
        a(((Bitmap) (null)), true, false);
    }

    public void a(float f1)
    {
        a(f1, (float)getWidth() / 2F, (float)getHeight() / 2F);
    }

    protected void a(float f1, float f2)
    {
        g.postTranslate(f1, f2);
    }

    protected void a(float f1, float f2, float f3)
    {
        if(f1 > k)
            f1 = k;
        float f4 = f1 / d();
        g.postScale(f4, f4, f2, f3);
        setImageMatrix(e());
        a(true, true);
    }

    protected void a(float f1, float f2, float f3, float f4)
    {
        float f5 = (f1 - d()) / f4;
        float f6 = d();
        long l1 = System.currentTimeMillis();
        l.post(new cls_o(this, f4, l1, f6, f5, f2, f3));
    }

    public void a(Bitmap bitmap, boolean flag, boolean flag1)
    {
        a(new cls_aj(bitmap), flag, flag1);
    }

    public void a(cls_aj aj1, boolean flag, boolean flag1)
    {
        int i1 = getWidth();
        m = flag1;
        if(i1 <= 0)
        {
            o = new cls_p(this, aj1, flag, flag1);
        } else
        {
            if(aj1.b() != null)
            {
                a(aj1, f, flag1);
                a(aj1.b(), aj1.a());
            } else
            {
                f.reset();
                setImageBitmap(null);
            }
            com.nnee.p_g.cls_b.c("setImageRotateBitmapResetBase", (new StringBuilder()).append("mDisplaybitmap==: ").append(h.b()).toString());
            if(flag)
                g.reset();
            setImageMatrix(e());
            k = f();
        }
    }

    public void a(cls_an an1)
    {
        e = an1;
    }

    public void a(cls_v v1)
    {
        d = v1;
    }

    protected void a(boolean flag, boolean flag1)
    {
    	float f4 =0;
        float f1 = 0F;
        RectF rectf=null;
        float f2=0;
        float f3=0;
        int j1=0;
        if(h.b() != null) {
        	
            Matrix matrix = e();
            rectf = new RectF(f1, f1, h.b().getWidth(), h.b().getHeight());
            matrix.mapRect(rectf);
            f2 = rectf.height();
            f3 = rectf.width();
            if(!flag1)
                return;
            j1 = getHeight();
            if(f2 >= (float)j1) {
            	if(rectf.top > f1)
                {
                    f4 = -rectf.top;
                } else
                {
                    if(rectf.bottom >= (float)j1)
                        return;
                    f4 = (float)getHeight() - rectf.bottom;
                }
                  
            }else {
            	f4 = ((float)j1 - f2) / 2F - rectf.top;
            }
        }
        
        if(flag)
        {
            int i1 = getWidth();
            if(f3 < (float)i1)
                f1 = ((float)i1 - f3) / 2F - rectf.left;
            else
            if(rectf.left > f1)
                f1 = -rectf.left;
            else
            if(rectf.right < (float)i1)
                f1 = (float)i1 - rectf.right;
        }
        a(f1, f4);
        setImageMatrix(e());
        
    }

    public void b()
    {
        b(1.25F);
    }

    protected void b(float f1)
    {
        if(d() < k && h.b() != null)
        {
            float f2 = (float)getWidth() / 2F;
            float f3 = (float)getHeight() / 2F;
            g.postScale(f1, f1, f2, f3);
            setImageMatrix(e());
        }
    }

    protected void b(float f1, float f2)
    {
        a(f1, f2);
        setImageMatrix(e());
    }

    public void b(float f1, float f2, float f3)
    {
        if(f1 > k)
            f1 = k;
        float f4 = d();
        float f5 = f1 / f4;
        if(f1 < 1F)
            f5 = 1F / f4;
        g.postScale(f5, f5, f2, f3);
        setImageMatrix(e());
        a(true, true);
    }

    protected void b(Matrix matrix)
    {
        g.postConcat(matrix);
        setImageMatrix(e());
        a(true, true);
    }

    public void c()
    {
        c(1.25F);
    }

    public void c(float f1)
    {
        if(h.b() != null)
        {
            float f2 = (float)getWidth() / 2F;
            float f3 = (float)getHeight() / 2F;
            Matrix matrix = new Matrix(g);
            matrix.postScale(1F / f1, 1F / f1, f2, f3);
            if(a(matrix) < 1F)
                g.setScale(1F, 1F, f2, f3);
            else
                g.postScale(1F / f1, 1F / f1, f2, f3);
            setImageMatrix(e());
            a(true, true);
        }
    }

    public void c(float f1, float f2, float f3)
    {
        float f4 = (float)getWidth() / 2F;
        float f5 = (float)getHeight() / 2F;
        b(f4 - f2, f5 - f3);
        a(f1, f4, f5);
    }

    public float d()
    {
        return a(g);
    }

    public Matrix e()
    {
        b.set(f);
        b.postConcat(g);
        return b;
    }

    public float f()
    {
        float f1;
        if(h.b() == null)
            f1 = 1F;
        else
            f1 = 4F * Math.max((float)h.f() / (float)i, (float)h.e() / (float)j);
        return f1;
    }

    public Bitmap g()
    {
        Bitmap bitmap;
        if(h != null)
            bitmap = h.b();
        else
            bitmap = null;
        return bitmap;
    }

    protected void onDetachedFromWindow()
    {
        super.onDetachedFromWindow();
        if(h != null)
            h.g();
 
        return;
        
    }

    protected void onLayout(boolean flag, int i1, int j1, int k1, int l1)
    {
        super.onLayout(flag, i1, j1, k1, l1);
        i = k1 - i1;
        j = l1 - j1;
        Runnable runnable = o;
        if(runnable != null)
        {
            o = null;
            runnable.run();
        }
        if(h.b() != null)
        {
            a(h, f, m);
            setImageMatrix(e());
        }
        if(d != null)
            d.a();
    }

    public void setImageBitmap(Bitmap bitmap)
    {
        a(bitmap, 0);
    }

    private static final String a = "ImageViewTouchBase";
    static final float n = 1.25F;
    private final Matrix b;
    private final float c[];
    private cls_v d;
    private cls_an e;
    protected Matrix f;
    protected Matrix g;
    protected cls_aj h;
    int i;
    int j;
    public float k;
    protected Handler l;
    boolean m;
    private Runnable o;
}
